<?php

	header('Content-Type: text/html;charset=ISO-8859-1');
        ?>
<style type="text/css"><?php
	require('CSS.css');

        ?>
    </style>
<script type="text/javascript">
        <?php
require('javascript.js');

?>
</script>
<?php

if (isset($_GET['valider']))
{
	$errors = array();
	$champs = array("appname","author","version","desktopicon","programicon","width","height","initfile");
	
	foreach ($champs as $champ)
	{
		if (!isset($_GET[$champ]) || (empty($_GET[$champ]) && ($champ != "desktopicon" && $champ != "programicon" )))
		{
			echo "Le champ : ".$champ." semble vide ou n'est pas pass�.";
			$errors[] = $champ;
		}
	}
	
	if (empty($errors))
	{
		echo "<legend>Code g�n�r�</legend>";
		
		if (empty($_GET["desktopicon"]) || $_GET["desktopicon"] == "Icone du bureau")
		{
			$_GET["desktopicon"] = "default";
		}
		if (empty($_GET["programicon"]) || $_GET["programicon"] == "Icone du programme")
		{
			$_GET["programicon"] = "default";
		}
		
		echo "<fieldset class='codefieldset'><legend>Conf.xml</legend><pre>".htmlspecialchars(
		"<?xml version='1.0'?>
		<appdata>
			<infos>
				<appname>".$_GET["appname"]."</appname>
				<author>".$_GET["author"]."</author>
				<version>".$_GET["version"]."</version>
			</infos>
			<config>
				<desktopicon>".$_GET["desktopicon"]."</desktopicon>
				<programicon>".$_GET["programicon"]."</programicon>
				<width>".$_GET["width"]."</width>
				<height>".$_GET["height"]."</height>
				<resizable>".$_GET["resizable"]."</resizable>
				<movable>".$_GET["movable"]."</movable>
				<autofullscreen>".$_GET["autofullscreen"]."</autofullscreen>
				<initfile>".$_GET["initfile"]."</initfile>
			</config>
		</appdata>"
		)."</pre></fieldset>";
		
		echo "<br /><br /><a href='#' onclick='Window_ReloadContent(\"CGen\",\"generator.php\");'>Essayer de nouveau";
	}
	
}
else
{

?>

<div id="CGen_MainFrame" style="overflow:auto; height:99%;">
	<div id="CGen_TitleDiv">Conf.xml Generator</div>
	
	<fieldset>
	
		<legend>Configuration souhait�e</legend>
		
		<form method="get" onsubmit="this.parentNode.innerHTML = GenCode(this);return false;" action="">
			<fieldset>
			
				<legend>Informations</legend>
				<input type="text" name="appname" value="Nom de l'application" />
				<input type="text" name="author" value="Nom de l'auteur" />
				<input type="text" name="version" value="Version de l'application" />
				
			</fieldset>
			<fieldset>
			
				<legend>Options</legend>
				<input type="text" name="desktopicon" value="Icone du bureau" /> (typiquement : /Res/Icone/MON_APP32.png)* <br />
				<input type="text" name="programicon" value="Icone du programme" /> (typiquement : /Res/Icone/MON_APP16.png)* <br />
				<input type="text" name="width" value="Largeur de l'application" /> px<br />
				<input type="text" name="height" value="Hauteur de l'application" /> px<br />
				<input type="checkbox" name="resizable" /> Application retaillable <br />
				<input type="checkbox" name="movable" /> Application d�pla�able <br />
				<input type="checkbox" name="autofullscreen" /> Plein �cran automatique <br />
				<input type="text" name="initfile" value="Fichier d'initialisation" /><br /><br />
				
				*Laisser vide ou � la valeur par d�faut si vous ne souhaitez pas indiquer de chemin.<br /><br />
				<input type="submit" name="valider" value="Valider" />
			
			</fieldset>
		</form>
		
	</fieldset>
</div>

<?php
}
?>